package com.tsingtao.springboot2.api.controller;

import com.tsingtao.springboot2.dto.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/exercise1")
public class Exercise1Controller {

    @GetMapping("/test1")
    public Integer test1(@RequestParam Integer id) {
        log.info("" + id);
        return id * 100;
    }

    @GetMapping("/test11/{id}")
    public Integer test11(@PathVariable(name = "id") Integer idd) {
        log.info("" + idd);
        return idd * 100;
    }

    @PostMapping("/test2")
    public User test2(@RequestBody User user) {
        User build = User.builder().name(user.getName()).age(user.getAge()).build();
        return build;
    }

    @PutMapping("/test3")
    public User test3(@RequestBody User user) {
        User build = User.builder().name(user.getName()).age(user.getAge()).mark("已成年").build();
        return build;
    }

    @DeleteMapping("/test4")
    public String test4(@RequestBody User user) {
        return "张三信息已删除";
    }

}


